package com.learn.excel.core.util;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: 杜海强
 * @description:
 * @date: 2021/5/28 15:04
 */
public class StringUtil {

    /***
     * 逗号分隔的Int转List
     * @param str
     * @return
     */
    public static List<Integer> strToInts(String str) {
        List<String> idStr = Lists.newArrayList(str.split(","));
        List<Integer> ids = idStr.stream()
                .filter(it -> StringUtils.isNotBlank(it))
                .distinct()
                .map(s -> Integer.parseInt(s.trim()))
                .collect(Collectors.toList());
        return ids;
    }
}
